Skip to content

close email connections when done #6496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

escattone
Copy link
Contributor

@escattone escattone commented Feb 6, 2025

mozilla/sumo#2179 (and part of mozilla/sumo#1993)

Notes

  • An instance of the django.core.mail.backends.smtp.EmailBackend class -- which is what django.core.mail.get_connection returns -- is a Python context manager, so it'll automatically take care of opening and closing the connection when used in a with statement.
  • This PR ensures that all of SUMO's email connections are closed after they've been used. Every email in SUMO is ultimately sent from either the kitsune.sumo.email_utils.send_messages function or the kitsune.tidings.events.Event.send_emails method.

@escattone escattone requested a review from akatsoulas February 6, 2025 20:36
Copy link
Collaborator

@akatsoulas akatsoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change with big impact, regardless if it fixes the problem or not.

Probably this should go with the ratelimit PR but there's also the send_mass_mail that we could look into which sends multiple emails efficiently with a single connection

@akatsoulas akatsoulas merged commit 0ddffe6 into mozilla:main Feb 7, 2025
2 checks passed
@escattone escattone deleted the email-connection-hygiene branch February 7, 2025 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants